# 2024/4/17 下午3:01 HFL
import json
import os


def _assert(response,status,code,ok):
    assert status == response.status_code
    assert code == response.json().get("code")
    assert ok == response.json().get('ok')






# 获取当前的根路径
base_path = os.path.dirname(__file__)

def read_json(filename,apiname):
    """
    读取json文件，并将转换为列表嵌套元组的数据形式
    :param filename:
    :param apiname:
    :return:
    """
    # 获取到的json文件位置
    path = base_path +f"../../datas/{filename}.json"
    # json文件进行读取
    with open(path,encoding='utf-8') as f :
        data = json.load(f)
    # 取到想要的接口数据
    data_dict = data.get(apiname)
    # 创建一个空列表
    data_list = list()
    # 遍历字典
    for i in data_dict:
        # 将取到的数据放进data_list列表里面
        data_list.append(tuple(i.values()))
    # 将数据返回出去
    return data_list





if __name__ == '__main__':
    print(read_json("login_data", "login"))
